package org.will.common;

import java.io.File;
import java.util.*;

import org.reveno.atp.core.RevenoConfiguration;
import org.reveno.atp.core.storage.FileSystemStorage;

/**
 * Created by EdifierWill on 2016/8/11.
 */
public class ExtSnapshotStorage extends FileSystemStorage {

    @Override
    public void move(SnapshotStore from, SnapshotStore to) {

        //ԭʼ
        //(new File(this.baseDir, from.getSnapshotPath())).renameTo(new File(this.baseDir, to.getSnapshotPath()));

        //hot fix for windows temp
        String tempName = UUID.randomUUID().toString();
        (new File(this.baseDir, to.getSnapshotPath())).renameTo(new File(this.baseDir, tempName));
        (new File(this.baseDir, from.getSnapshotPath())).renameTo(new File(this.baseDir, to.getSnapshotPath()));
        (new File(this.baseDir, tempName)).renameTo(new File(this.baseDir, from.getSnapshotPath()));
    }

    public ExtSnapshotStorage(File baseDir, RevenoConfiguration.RevenoJournalingConfiguration config) {
        super(baseDir,config);
    }
}
